<%-- 
    Document   : sendConfession
    Created on : Nov 12, 2013, 8:24:43 PM
    Author     : BAOLA
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">
<%@taglib uri="/struts-tags" prefix="s" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/xml" prefix="x"%>
<jsp:include page="header.jsp"/>
<c:set var="pageId" scope="session" value="${param.pageId}"/>
<script type="text/javascript">
    function validateForm(form) {
        var confess = form.confess.value;
        var error = [];
        if (confess.length == 0) {
            error[error.length] = "Please enter confession's message";
        }
        if (error.length > 0) {
            reportError(error);
            return false;
        }
        return true;
    }
     function reportError(error) {
        var error_container = document.getElementById("error-container");
        var error_ol = document.getElementById("error-ol");
        error_ol.innerHTML = "";
        for (i = 0; i < error.length; i++) {
            error_ol.innerHTML += '<li><label for="name" class="error">' +error[i]+ '</label></li>';
        }
        error_container.style.display = 'block';
        error_ol.style.display = 'block';
    }
</script>
<c:if test="${not empty pageId}">
    <div class="mid-wrapper">
        <div class="container-fluid">

            <div id="error-container" class="error-container" style="display: none;">
                            <h4>Errors occur, please see below for detail</h4>
                            <ol id="error-ol" style="display: none;"></ol>
                        </div>
            <c:if test="${not empty param.message}">
                <tr>
                    <td>
                        <h4>Your confession has been sent. Please wait the manager approve it ^^!</h4>
                    </td>

                </tr>
            </c:if>
            <c:import url="WEB-INF/xml/page.xml" var="xml" charEncoding="UTF-8"/>
            <c:import url="WEB-INF/xsl/sendConfession.xsl" var="xsl" charEncoding="UTF-8"/>
            <x:transform xml="${xml}" xslt="${xsl}">
                <x:param name="pageId" value="${pageId}"/>
            </x:transform>

        </div>
    </div>
</c:if>

<jsp:include page="footer.jsp"/>
